<template>
  <div class="system-config-container">
    <ContentWrap class="config-wrapper">
      <!-- 页面头部 -->
      <div class="config-header">
        <div class="header-icon">
          <Icon icon="ep:setting" />
        </div>
        <div class="header-content">
          <h3 class="config-title">系统配置管理</h3>
          <p class="config-subtitle">管理客服系统的各项配置信息</p>
        </div>
      </div>

      <!-- 标签页容器 -->
      <div class="tabs-container">
        <el-tabs v-model="activeName" class="enhanced-tabs">
          <el-tab-pane label="欢迎语配置" name="welcome">
            <template #label>
              <div class="tab-label">
                <Icon icon="ep:chat-line-round" class="tab-icon" />
                <span class="tab-text">欢迎语配置</span>
              </div>
            </template>
            <div class="tab-content">
              <Welcome></Welcome>
            </div>
          </el-tab-pane>

          <el-tab-pane label="自动回复配置" name="autoReply">
            <template #label>
              <div class="tab-label">
                <Icon icon="ep:chat-dot-round" class="tab-icon" />
                <span class="tab-text">自动回复配置</span>
              </div>
            </template>
            <div class="tab-content">
              <AutoReply></AutoReply>
            </div>
          </el-tab-pane>

          <el-tab-pane label="场景配置" name="scene">
            <template #label>
              <div class="tab-label">
                <Icon icon="ep:menu" class="tab-icon" />
                <span class="tab-text">场景配置</span>
              </div>
            </template>
            <div class="tab-content">
              <Scene></Scene>
            </div>
          </el-tab-pane>

          <el-tab-pane label="客服简介配置" name="introconfig">
            <template #label>
              <div class="tab-label">
                <Icon icon="ep:user" class="tab-icon" />
                <span class="tab-text">客服简介配置</span>
              </div>
            </template>
            <div class="tab-content">
              <Introconfig></Introconfig>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </ContentWrap>
  </div>
</template>

<script setup lang="ts">
import Welcome from './welcome/index.vue'
import AutoReply from './autoReply/index.vue'
import Scene from './scene/index.vue'
import Introconfig from './introconfig/index.vue'

defineOptions({ name: 'ServiceSystemConfig' })

const activeName = ref('welcome')
</script>

<style lang="scss" scoped>
// 主题色变量
$primary-color: #0052cc;
$primary-light: rgba(0, 82, 204, 0.1);
$primary-border: rgba(0, 82, 204, 0.3);
$text-primary: #303133;
$text-regular: #606266;
$text-secondary: #909399;
$text-placeholder: #c0c4cc;
$border-color: #dcdfe6;
$border-light: #e4e7ed;
$bg-color: #f5f7fa;
$shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
$shadow-base:
  0 2px 4px rgba(0, 0, 0, 0.12),
  0 0 6px rgba(0, 0, 0, 0.04);
$border-radius: 12px;
$border-radius-small: 8px;

.system-config-container {
  padding: 16px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;

  @media (max-width: 768px) {
    padding: 8px;
  }
}

.config-wrapper {
  border-radius: $border-radius;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 82, 204, 0.1);
  background: white;
}

/* 页面头部样式 */
.config-header {
  display: flex;
  align-items: center;
  padding: 24px;
  background: linear-gradient(135deg, $primary-color 0%, #1d4ed8 100%);
  color: white;
  border-radius: 10px 10px 0 0;

  @media (max-width: 768px) {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

.header-icon {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: $border-radius-small;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;

  @media (max-width: 768px) {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

.header-content {
  flex: 1;
  margin-left: 16px;

  @media (max-width: 768px) {
    margin-left: 0;
  }
}

.config-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px 0;

  @media (max-width: 768px) {
    font-size: 18px;
  }
}

.config-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;

  @media (max-width: 768px) {
    font-size: 12px;
  }
}

/* 标签页容器 */
.tabs-container {
  padding: 0;
  background: white;
}

/* 增强的标签页样式 */
.enhanced-tabs {
  :deep(.el-tabs__header) {
    margin: 0;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
    border-bottom: 2px solid $border-light;
    padding: 0 24px;

    @media (max-width: 768px) {
      padding: 0 16px;
    }
  }

  :deep(.el-tabs__nav-wrap) {
    &::after {
      display: none;
    }
  }

  :deep(.el-tabs__nav-scroll) {
    @media (max-width: 768px) {
      overflow-x: auto;
      overflow-y: hidden;
      white-space: nowrap;
    }
  }

  :deep(.el-tabs__nav) {
    @media (max-width: 768px) {
      display: flex;
      min-width: max-content;
    }
  }

  :deep(.el-tabs__item) {
    padding: 16px 20px;
    font-weight: 500;
    color: $text-secondary;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    background: transparent;
    border-radius: 0;

    @media (max-width: 768px) {
      padding: 12px 16px;
      font-size: 14px;
      flex-shrink: 0;
    }

    @media (max-width: 480px) {
      padding: 10px 12px;
      font-size: 13px;
    }

    &:hover {
      color: $primary-color;
      background: rgba(0, 82, 204, 0.05);
    }

    &.is-active {
      color: $primary-color;
      // border-bottom-color: $primary-color;
      // background: rgba(0, 82, 204, 0.08);
      font-weight: 600;

      // &::before {
      //   content: '';
      //   position: absolute;
      //   top: 0;
      //   left: 0;
      //   right: 0;
      //   height: 3px;
      //   background: linear-gradient(90deg, $primary-color 0%, lighten($primary-color, 10%) 100%);
      //   border-radius: 0 0 2px 2px;
      // }
    }
  }

  :deep(.el-tabs__content) {
    padding: 0;
    background: white;
  }

  :deep(.el-tab-pane) {
    background: white;
  }
}

/* 标签页标签样式 */
.tab-label {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;

  @media (max-width: 480px) {
    gap: 6px;
  }
}

.tab-icon {
  font-size: 16px;
  transition: all 0.3s ease;

  @media (max-width: 768px) {
    font-size: 14px;
  }

  @media (max-width: 480px) {
    font-size: 13px;
  }
}

.tab-text {
  transition: all 0.3s ease;

  @media (max-width: 480px) {
    display: none;
  }
}

/* 标签页内容样式 */
.tab-content {
  padding: 24px;
  min-height: 400px;
  background: white;

  @media (max-width: 768px) {
    padding: 16px;
    min-height: 300px;
  }

  @media (max-width: 480px) {
    padding: 12px;
    min-height: 250px;
  }
}

/* 响应式优化 */
@media (max-width: 768px) {
  .system-config-container {
    padding: 4px;
  }

  .config-wrapper {
    border-radius: $border-radius-small;
  }

  .enhanced-tabs {
    :deep(.el-tabs__header) {
      padding: 0 12px;
    }
  }
}

@media (max-width: 480px) {
  .enhanced-tabs {
    :deep(.el-tabs__header) {
      padding: 0 8px;
    }

    :deep(.el-tabs__item) {
      min-width: 60px;
      justify-content: center;
    }
  }

  .tab-content {
    padding: 8px;
  }
}

/* 滚动条美化 */
:deep(.el-tabs__nav-scroll) {
  &::-webkit-scrollbar {
    height: 4px;
  }

  &::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
  }

  &::-webkit-scrollbar-thumb {
    background: rgba(0, 82, 204, 0.3);
    border-radius: 2px;

    &:hover {
      background: rgba(0, 82, 204, 0.5);
    }
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .system-config-container {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  }

  .config-wrapper {
    background: #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .config-title {
    color: #f9fafb;
  }

  .tabs-container,
  .tab-content {
    background: #374151;
  }

  .enhanced-tabs {
    :deep(.el-tabs__header) {
      background: #4b5563;
      border-bottom-color: #6b7280;
    }

    :deep(.el-tabs__item) {
      color: #d1d5db;

      &:hover {
        color: #60a5fa;
        background: rgba(96, 165, 250, 0.1);
      }

      &.is-active {
        color: #60a5fa;
        // border-bottom-color: #60a5fa;
        // background: rgba(96, 165, 250, 0.15);

        &::before {
          background: linear-gradient(90deg, #60a5fa 0%, #93c5fd 100%);
        }
      }
    }

    :deep(.el-tab-pane) {
      background: #374151;
    }
  }
}

/* 动画效果 */

/* 加载状态优化 */
:deep(.el-loading-mask) {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(2px);

  .el-loading-spinner {
    .path {
      stroke: $primary-color;
    }
  }
}
</style>
